<template>
	<div style="width: 100%;">
		<div style="display: flex; width: 100%;">
			<el-button size="default" type="danger" style="background-color: #E1337F;" @click="add()">
				<el-icon><Plus /></el-icon>添加</el-button>
			<div style="width: 100%;"><p style="text-align: center;">热度管理</p></div>
			<div style="margin-left: auto;">
				<el-button size="default" type="danger" style="background-color: #E1337F;" @click="refresh()">
					<el-icon><Loading /></el-icon>刷新</el-button>
			</div>
		</div>
		&emsp;
		<div style="background-color: #E1337F;height: 0.1rem;"/>
		<el-card >
		<div style="width: 100%;">
		<el-table :data="data.hot" style="width: 100%">
			<el-table-column prop="hotid" label="编号" />
			<el-table-column prop="memo" label="描述" />
			<el-table-column label="图片">
				<template #default="car">
					<el-image style="width: 100px;height: 100px;"
						:src="$ip+`/public/shows/`+car.row.pic" />
				</template>
			</el-table-column>
			<el-table-column prop="heat" label="热度" />
			<el-table-column prop="type.typeid" label="类型" />
			<el-table-column label="操作"><template #default="car">
					<el-button style="background-color: #E1337F;" size="default" type="danger" @click.prevent="del(car.row.hotid)">
						<el-icon>
							<Delete />
						</el-icon>删除
					</el-button>
				</template></el-table-column>
		</el-table>

		
		</div>
		</el-card >
	</div>
	
</template>

<script lang="ts" setup>
	import {ref, reactive,onMounted,computed} from"vue"
		import {$get,$postx,$postj,$postf} from '../../ajax/index.js'
		import { ElMessage, ElMessageBox } from 'element-plus'
		import router from"../../router/index.js"
		import store from "../../store/index.js"
		import {Search,ShoppingCart,Plus,Delete,Loading} from '@element-plus/icons-vue'
		import bottom from "../../components/bottom.vue"
		import {useRoute} from "vue-router"
		import {success,warning,message,errors} from '../../store/alert.js'
	const data = reactive({
		hot:[{memo:"1",pic:"1"}]
	})
	
	
	function del(hotid){
		$get("/adm/hot/del/"+hotid).then((read)=>{
			
			if(read.data.code==401){
				errors(read.data.msg)
				
			}else{
				success(read.data.msg)
				data.hot=read.data.data
			}
			
		})
		
		
	}
	function refresh(){
		
		$get("/adm/hot/refresh").then((read)=>{
			data.hot=read.data.data
		})
	}
	function add(){
		router.push("/adm/addhot")
	}
	onMounted(()=>{
		$get("/adm/hot/findAll").then((read)=>{
			
			data.hot=read.data.data
			
		})
		
		
	})
	
</script>

<style>
</style>
